/**
 * Created by dave on 17/7/3.
 */
var app = new Vue({
    el: '#newContract',
    data: {
        //跟路径
        ctx: '',
        openId: '',
        applicationId: '',
        home: false,//主页面
        nextPage: true,//第二页
        idCardPicture: false,//身份证
        idCardHanding: false,//手持身份证
        other: false,//租客其他信息
        housingInfo: false,//房屋信息
        housingAddress: false,//房屋地址
        housingSource: false,//房源列表
        otherPromiseTips: false,//其他约定事项
        contract: false,//房租合同
        success: false,//成功页面
        submitSuccess: false,//提交成功
        endDate: '',//到期日期
        retainageDisable: true,
        start_date:$("#start_date_show").val(),
        end_date:$("#end_date_show").val(),
        //home_form
        homeForm: {
            openId: '',//隐藏域id
            applicationId: '',//申请id
            name: '',//姓名
            phone: '',//租客手机号
            identityNumber: '',//身份证号
            idCardFrontPhoto: '',//身份证正面
            idCardVersoPhoto: '',//身份证反面
            idCardAndPersonPhoto: '',//手持身份证照片
            contractPhotos: [],//租房合同照片
            province: '',//省
            city: '',//城市
            district: '',//县
            address: '',//详细地址
            apartmentNo: '',//房源编号
            version: '',//版本号
            //下面是电子合同需要的字段
            isElectroniContract: false,//电子合同是否打开
            electroniContractJson: {
                retainage: 0,
                startDate: '',
                endDate: '',
                use: '居住',
                peopleCount: '1',
                commissionDays: '',
                commission: '',
                commissionPayType: '',
                protectionFee: '300',
                depositCount: '一',
                prepaidCount: '一',
                tvFee: 0,
                managementFee: 0,
                sanitationFee: 0,
                lessorDuty: [],//甲方承担责任
                lesseeDuty: [1,2,3,4,5,6,7,8,9,10,11,12],//乙方承担责任
                lessorBreachMaxDays: 3,
                lessorBreachFee: 200,
                lesseeBreachMaxDays: 3,
                lesseeOweFeeMax: 300,
                lesseeBreachFee: 200,
                lesseeLateFee: 20,
                deliveryList: [],
                otherFeeList: [],
                monthlyRent: 0,
                agentName: '',
                agentTel: '',
                commitDate: '',
                customerName: '',
                customerTel: '',
                customerSign: '',
                roomCount: '',
                housingSourceNo: '',
                communityName: '',
                otherPromiseTips: '',
                CCC: '',
                otherDefaultsA: '',
                otherDefaultsB: ''
            },//电子合同对象
            housingSourceDataJson :{}//租客选择的房源json
        },
        //房屋信息form
        housingForm: {
            id: '',
            customerId: '',
            agentId: '',
            monthlyRent: '',//月租金
            startDate: '',
            endDate: '',
            endDateShow: '',
            retainage: 0,
            retainageMerge: false,//是否合并尾款
            startDateShow: '',//开始时间
            agentName: '',//经纪人
            applicationNo: ''
        },




        notClick: false,
        domain: '',//图片上传的路径
        statusName: '',//状态
        //下面是用来判断是否传入照片，消除提示的验证,提示字段改变
        idCardShow: "",
        idCardError: false,
        idCardClass: 'weui-reddot',
        idCardHandingShow: '',
        idCardHandingError: false,
        idCardHandingClass: 'weui-reddot',
        housingAddressShow: '',
        housingAddressError: false,
        housingAddressClass: 'weui-reddot',
        contractShow: '',
        contractError: false,
        contractClass: 'weui-reddot',
        othertip: '未修改',//租客其他信息修改提示
        housingInfotip: '未修改',//房屋信息修改提示
        Form: {},//返回的整体from
        //租客其他信息form
        otherForm: {
            applicationNo:''
        },

        //身份证存储src
        imgSrc: '',
        imgSrc2: '',
        //手持身份证
        imgSrchanding: '',
        //合同存储src
        imgSrccontract: '',
        //token
        token: '',
        //下面是为了记录房屋信息返回的时候选择的省市区
        sheng: '',
        shi: '',
        qu: '',
        //待修改状态下显示审批备注
        remarkShow: false,
        info: '',//记录待修改单据带过来的需要修改的信息
        cityPickDefault: [110000, 110100, 110101],//默认省市区
        //下面是电子合同所需要的date
        eleContractOpen: false,
        commissionOpen: false,
        fadeClass: 'fadeout',
        commissionClass: 'fadeout',
        depositAndFees: false,//押金及其他费用
        removeTerm: false,//合同解除条件
        housingList: false,//房屋交割清单
        otherList: false,//其他相关费用
        otherListDetail: false,//其他相关费用详情
        depositPickDefault: ['一','一'],//押金默认数组
        lessorDuty: [false,false,false,false,false,false,false,false,false,false,false,false],//甲方承担责任临时数组
        lesseeDuty: [true,true,true,true,true,true,true,true,true,true,true,true],//乙方承担责任临时数组
        deliveryList: [false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false],//房屋交割清单临时数组
        feeType1: 'depositClose',
        feeType2: 'depositClose',
        housingListClass1: 'housingListClose',
        housingListClass2: 'housingListClose',
        otherListClass1: 'housingListClose',
        otherListClass2: 'housingListClose',
        depositRotate1: '',//用来记录按钮旋转状态
        depositRotate2: '',
        housingListRotate1: '',
        housingListRotate2: '',
        otherListListRotate1: '',
        otherListListRotate2: '',
        feeType1Bloor1: true,//用来记录押金当前是关闭还是打开
        feeType1Bloor2: true,
        housingListBoolean1: true,//用来记录房屋清单List子项目是否打开
        housingListBoolean2: true,
        otherListBoolean1: true,//用来其他费用清单List子项目是否打开
        otherListBoolean2: true,
        otherListDetailDto: {
            items: '',
            startDate: '',
            baseCount: '',
            unit: '',
            monovalent: ''
        },
        otherListStatus: [false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false],//用来记录其他相关明细是否填写
        scrollTop: 0,
        handlerBoolear: false,
        housingSourceData:[],
        //小家联行房源所需参数
        start_id: 0,
        city_id: '',
        district_id: '',
        next_url: '',
        loadingMore: false,
        loadingNotMore: false,
        cityPickResult: [],//房屋地址选择的省市区县数组
        search: '',
        scrollFlag: true//记录是否滚动到底部过
    },
    created: function () {
        this.init();
    },
    mounted: function () {
    },
    methods: {
        init: function () {

        },
        //隐藏加载项
        hidenTags: function () {
            $('#loadingToast').addClass('weui-actionsheet_toggle').fadeOut(200);
        },
        //显示加载项
        showTags: function () {
            $('#loadingToast').removeClass('weui-actionsheet_toggle').fadeIn(200);
        },
        //dataPicker
        datePickerStart: function () {
            var that = this;
            weui.datePicker({
                start:2017,
                end:2020,
                defaultValue: [2017,7,14],
                onChange: function(result){
                },
                onConfirm: function(result){
                    if(result[1].value < 10){
                        if(result[2].value < 10){
                            $("#startDate").val(dateFns.format(result[0].value + '-'+'0' + result[1].value + '-' + '0' + result[2].value,'YYYY-MM-DD'));
                        } else {
                            $("#startDate").val(dateFns.format(result[0].value + '-'+'0' + result[1].value + '-' + result[2].value,'YYYY-MM-DD'));
                        }
                    } else {
                        if(result[2].value < 10){
                            $("#startDate").val(dateFns.format(result[0].value + '-' + result[1].value + '-' + '0' + result[2].value,'YYYY-MM-DD'));
                        } else {
                            $("#startDate").val(dateFns.format(result[0].value + '-' + result[1].value + '-' + result[2].value,'YYYY-MM-DD'));
                        }
                    }
                    that.dateChange();
                },
                id: 'datePickerStart'
            });
        },
        datePickerEnd: function () {
            if($("#startDate").val() === ''){
                $.toptips("请输入起租日期");
                return;
            }
            var that = this;
            var startDate = dateFns.format(dateFns.subDays(dateFns.addMonths($("#startDate").val(), 2),1),'YYYY-MM-DD');
            var endDate = dateFns.format(dateFns.addMonths($("#startDate").val(), 13),'YYYY-MM-DD');
            weui.datePicker({
                start:startDate,
                end:endDate,
                onChange: function(result){
                },
                onConfirm: function(result){
                    if(result[1].value < 10){
                        if(result[2].value < 10){
                            $("#endDate").val(dateFns.format(result[0].value + '-'+'0' + result[1].value + '-' + '0' + result[2].value,'YYYY-MM-DD'));
                        } else {
                            $("#endDate").val(dateFns.format(result[0].value + '-'+'0' + result[1].value + '-' + result[2].value,'YYYY-MM-DD'));
                        }
                    } else {
                        if(result[2].value < 10){
                            $("#endDate").val(dateFns.format(result[0].value + '-' + result[1].value + '-' + '0' + result[2].value,'YYYY-MM-DD'));
                        } else {
                            $("#endDate").val(dateFns.format(result[0].value + '-' + result[1].value + '-' + result[2].value,'YYYY-MM-DD'));
                        }
                    }
                    that.dateChange();
                },
                id: 'datePickerEnd'
            });
        },
        dateChange: function () {
            var that = this;
            var start =dateFns.format($("#startDate").val(),'YYYY-MM-DD');
            var end = dateFns.format($("#endDate").val(),'YYYY-MM-DD');
            var monthMoney = $("#request_form").find("input[name=monthlyRent]").val();
            if(monthMoney !== '' && start !== 'NaN-NaN-NaN' && end !== 'NaN-NaN-NaN'){
                axios.get(that.ctx + '/wxtest/v2/applications/getLastDay?startDate='+start+'&endDate='+end+'').then(function(res){
                    $("#request_form").find("input[name=retainage]").val((monthMoney/30*res.data).toFixed(2));
                });
            }
        },
        //提交from，下一步
        next: function () {
            var that = this;
            var monthlyRent = $("#request_form").find("input[name=monthlyRent]").val();
            var monthlyRentValid = /^([1-9][0-9]*)+(.[0-9]{1,2})?$/.test(monthlyRent);
            if (monthlyRent == null || monthlyRent.trim() == "") {
                $.toptips("请输入月租金");
                return;
            }
            if(!monthlyRentValid){
                $.toptips("月租金为保留两位小数的正整数");
                return;
            }

            var startDate = $("#startDate").val();
            if (startDate == null || startDate.trim() == "") {
                $.toptips("请输入起租日期");

                return;
            }
            var endDate = $("#endDate").val();
            if (endDate == null || endDate.trim() == "") {
                $.toptips("请输入到期日期");
                return;
            }

            var retainage = $("#request_form").find("input[name=retainage]").val();
            if(Number(retainage) < 300) {
                $("#request_form").find("input[name=retainageMerge]").val(true)
            } else {
                $("#request_form").find("input[name=retainageMerge]").val(false)
            }
            var retainageValid = /^([1-9][0-9]*)+(.[0-9]{1,2})?$/.test(Number(retainage));
            if (retainage == null || retainage.trim() == "") {
                $.toptips("请输入尾款，无尾款输入0");
                return;
            }
            if(Number($("#retainage").val()) != 0){
                if(!retainageValid){
                    $.toptips("尾款不能小于0");
                    return;
                }
            }

            var phone = $("#request_form").find("input[name=mobile]").val();
            var phoneValid = /^(((13[0-9]{1})|(15[0-9]{1})|(14[0-9]{1})|(17[0-9]{1})|(18[0-9]{1}))+\d{8})$/.test(phone);
            if (phone == null || phone.trim() == "") {
                $.toptips("请输入手机号");
                return;
            }
            if(!phoneValid){
                $.toptips("请输入正确格式的手机号");
                return;
            }

            if (!validateCodeFlag) {
                $.toptips("请先发送验证码");
                return;
            }

            var validateCode = $("#request_form").find("input[name=validateCode]").val();
            if (validateCode == null || validateCode.trim() == "") {
                $.toptips("请输入验证码");
                return;
            }

            startDate = startDate+" 00:00:00";
            var end = $("#endDate").val()+" 00:00:00";

            $("#request_form").find("input[name=startDate]").val(startDate);
            $("#request_form").find("input[name=endDate]").val(end);
            this.showTags();
            var url = that.ctx + "/wxtest/v2/applications/create";

            var param = $("#request_form").serialize();
            /*$.post(url,param,function(data){
                that.hidenTags();

                if (data.status ==200) {
                    var openId = $("#_openId").val();
                    window.location.href="/customer/application/info/"+data.data.id+"?openId="+openId;
                } else {
                    $.toptips(data.data.message);
                }

            },"json");*/


            $.ajax({
                url: url ,
                data:param,
                dataType: "json",
                type: "post",
                success: function (data) {
                    that.hidenTags();
                    if(data && data.status && data.status !==200){
                        $.toptips(data.message);
                    }else {
                        var openId = $("#_openId").val();
                        window.location.href=that.ctx + "/customer/application/info/"+data.data.id+"?openId="+openId;
                    }
                },
                error: function (xhr) {
                    that.hidenTags();
                    if(xhr.status === 403){
                        $.toptips(JSON.parse(xhr.response).message);
                    } else{
                        $.toptips("系统错误");
                    }
                }
            });
        },



        //search
        labelClick: function () {
            $("#labelClick").css("display","none");
            $('#searchInput').focus();
        },
        inputBlur: function () {
            $("#labelClick").css("display","block");
        },
        searchClick: function () {
            var that = this;
            console.log(this.search);
            axios.get(encodeURI('/api/partners/rooms?app_id=libfintech&city_id='+this.city_id+'&district_id='+this.district_id+'&charge_num='+this.search)).then(function(res) {
                if(res.data.data.rooms.length === 0) {
                    weui.topTips("没有查到相应信息");
                } else {
                    that.housingSourceData = res.data.data.rooms
                }
            });

            $("#labelClick").css("display","block");
        },
        cancleSubmit: function () {
            $('#iosDialog1').fadeOut(200);
            this.notClick = false;
        },
        //提交电子合同
        submitForm: function () {
            var that = this;
            //loading
            $('#iosDialog1').fadeOut(200);
            this.showTags();
            axios.put(that.ctx + '/wxtest/v2/applications/apply',this.homeForm).then(function(res){
                console.log("返回信息res.data"+JSON.stringify(res.data));
                that.notClick = false;
                if (res.data && res.data.status && res.data.status !== 200) {
                    $.toptips(res.data.message);
                    that.hidenTags();
                }else{
                    that.home = false;
                    that.submitSuccess  =true;
                    that.hidenTags();
                }
            }).catch(function (error) {
                console.log(error.response);
                $.toptips(error.response.data.message);
                that.notClick = false;
                that.hidenTags();
            });
        },
        // 普通提交
        submitFormNormal: function () {
            //获取版本号
            this.homeForm.version  = $('#version').val();
            if(this.notClick){
                return false;
            }
            this.notClick = true;
            var that = this;
            //自己写的针对WEUI的验证，后期可以封装
            //待修改状态下不需要前端验证
            if(this.Form.statusName !== '待修改'){
                var name_val = $("#name").val();
                if (name_val == '') {
                    $.toptips("请输入名字");
                    $("#name").parent().parent().attr("class", "weui_cell weui_cell_warn");
                    this.notClick = false;
                    return false;
                }
                var valid_tel = /^(((13[0-9]{1})|(15[0-9]{1})|(14[0-9]{1})|(17[0-9]{1})|(18[0-9]{1}))+\d{8})$/.test($("#tel").val());
                if ($("#tel").val() == '' && name_val != '') {
                    $.toptips("请输入手机号");
                    $("#tel").parent().parent().attr("class", "weui_cell weui_cell_warn");
                    this.notClick = false;
                    return false;
                }

                if (valid_tel === false && ($("#tel").val() !== '')) {
                    $.toptips("请输入正确的手机号");
                    $("#tel").parent().parent().attr("class", "weui_cell weui_cell_warn");
                    this.notClick = false;
                    return false;
                }
                var valid_idCard = /^(\d{15}$|^\d{18}$|^\d{17}(\d|X|x))$/.test($("#idCard").val());
                if ($("#idCard").val() === '' && valid_tel === true) {
                    $.toptips("请输入身份证号");
                    $("#idCard").parent().parent().attr("class", "weui_cell weui_cell_warn");
                    this.notClick = false;
                    return false;
                }
                if (valid_idCard === false && ($("#idCard").val() !== '')) {
                    $.toptips("请输入有效的身份证号");
                    $("#idCard").parent().parent().attr("class", "weui_cell weui_cell_warn");
                    this.notClick = false;
                    return false;
                }

                if(this.homeForm.idCardFrontPhoto === '' || this.homeForm.idCardVersoPhoto === ''){
                    $.toptips("请补充身份证照片");
                    this.notClick = false;
                    return false;
                }
                if(this.homeForm.idCardAndPersonPhoto === ''){
                    $.toptips("请补充手持身份证照片");
                    this.notClick = false;
                    return false;
                }
                if(this.homeForm.contractPhotos.length === 0 && this.eleContractOpen === false){
                    $.toptips("请补充合同照片");
                    this.notClick = false;
                    return false;
                }
                if(this.housingAddressError === false){
                    $.toptips("请补充房屋地址");
                    this.notClick = false;
                    return false;
                }
            }

            //下面开始向后台传输数据
            that.homeForm.electroniContractJson.retainage = that.housingForm.retainage;
            that.homeForm.electroniContractJson.startDate = that.housingForm.startDateShow;
            that.homeForm.electroniContractJson.endDate = that.housingForm.endDateShow;
            that.homeForm.electroniContractJson.monthlyRent = that.housingForm.monthlyRent;
            that.homeForm.electroniContractJson.agentName = that.Form.agentName;
            that.homeForm.electroniContractJson.agentTel = that.Form.agentPhone;
            that.homeForm.electroniContractJson.customerName = that.Form.customerName;
            that.homeForm.electroniContractJson.customerTel = that.Form.phone;
            that.homeForm.electroniContractJson.lessee = that.Form.customerName;
            that.homeForm.electroniContractJson.lesseeCode = that.Form.customer.identityNumber;
            that.homeForm.electroniContractJson.address = that.homeForm.address;
            if(this.homeForm.isElectroniContract) {
                //使用电子合同
                $('#iosDialog1').fadeIn(200);
            } else {
                //loading
                this.showTags();
                axios.put(that.ctx + '/wxtest/v2/applications/apply',this.homeForm).then(function(res){
                    that.notClick = false;
                    if (res.data.status === 200) {
                        that.home = false;
                        that.submitSuccess  =true;
                        that.hidenTags();
                    }else{
                        $.toptips(res.data.message);
                        that.hidenTags();
                    }
                })
            }
        },
        //取消申请
        cancelForm: function () {
            var that = this;
            $.confirm("您确定要取消申请吗?", "确认取消申请", function() {
                axios.put(that.ctx + '/wxtest/v2/applications/cancleRequest/'+that.applicationId).then(function(res){

                    if (res.data.status === 200) {
                        that.home = false;
                        that.success = true;
                    }else{
                        $.toptips(res.data.message);
                    }
                });
            }, function() {
                //取消操作
            });

        },
        //点击验证选项时候，验证消失
        errorClick: function (a) {
            $(a).parent().parent().attr("class", "weui_cell");
        },
        //上传身份证
        uploadIdCard1: function () {
            var that = this;
            //获取token
            axios.get(that.ctx + '/api/v2/upload/getToken').then(function (res) {
                console.log(res.data);
                if (res.data) {
                    that.token = res.data;
                }
            });


            //formdata  start
            var $key = $('#key');  // file name    eg: the file is image.jpg,but $key='a.jpg', you will upload the file named 'a.jpg'
            var $userfile = $('#userfile');  // the file you selected

            // upload info
            var $selectedFile = $('.selected-file');
            var $progress = $(".progress1");
            var $uploadedResult = $('.uploaded-result');

            $("#userfile").change(function () {  // you can ues 'onchange' here to uplpad automatically after select a file
                $uploadedResult.html('');
                var selectedFile = $userfile.val();
                if (selectedFile && selectedFile.toLowerCase().match(/\.(jpg|jpeg|png)$/)) {
                    // randomly generate the final file name
                    var ramdomName = Math.random().toString(36).substr(2) + $userfile.val().match(/\.?[^.\/]+$/);
                    $key.val(ramdomName);
                    $selectedFile.html('文件：' + selectedFile);
                } else {
                    $.toptips("图片格式不正确");
                    return false;
                }
                var f = new FormData(document.getElementById("testform"));
                $.ajax({
                    url: upload_domain,  // Different bucket zone has different upload url, you can get right url by the browser error massage when uploading a file with wrong upload url.
                    type: 'POST',
                    data: f,
                    processData: false,
                    contentType: false,
                    xhr: function () {
                        myXhr = $.ajaxSettings.xhr();
                        if (myXhr.upload) {
                            myXhr.upload.addEventListener('progress', function (e) {
                                if (e.lengthComputable) {
                                    var percent = e.loaded / e.total * 100;
                                    $progress.html('正在上传：'+ percent.toFixed(2) + "%");
                                    if(percent === 100){
                                        $progress.html(' ');
                                    }
                                }
                            }, false);
                        }
                        return myXhr;
                    },
                    success: function (res) {
                        console.log("成功：" + JSON.stringify(res));
                        console.log(res.key);
                        if (res.key) {
                            console.log("上传成功");
                            // that.imgSrc = domain + res.key;
                            //本地上传的时候为了快速的预览照片，可以采用URL对象
                            that.imgSrc = URL.createObjectURL(document.querySelector("#userfile").files[0]);
                            that.homeForm.idCardFrontPhoto = res.key;
                            // console.log(that.imgSrc);
                            $("#hiddenImg").css("display", "block");
                        }
                    },
                    error: function (res) {
                        console.log("失败:" + JSON.stringify(res));
                        $uploadedResult.html('上传失败：' + res.responseText);
                        $.toptips("失败:" + JSON.stringify(res));
                    }
                });
                return false;
            });
            //formdata  end


        },
        uploadIdCard2: function () {
            var that = this;
            //获取token
            axios.get(that.ctx + '/api/v2/upload/getToken').then(function (res) {
                console.log(res.data);
                if (res.data) {
                    that.token = res.data;
                }
            });


            //formdata  start
            var $key = $('#key');  // file name    eg: the file is image.jpg,but $key='a.jpg', you will upload the file named 'a.jpg'
            var $userfile = $('#userfile1');  // the file you selected

            // upload info
            var $selectedFile = $('.selected-file');
            var $progress = $(".progress2");
            var $uploadedResult = $('.uploaded-result');

            $("#userfile1").change(function () {  // you can ues 'onchange' here to uplpad automatically after select a file
                $uploadedResult.html('');
                var selectedFile = $userfile.val();
                if (selectedFile && selectedFile.toLowerCase().match(/\.(jpg|jpeg|png)$/)) {
                    // randomly generate the final file name
                    var ramdomName = Math.random().toString(36).substr(2) + $userfile.val().match(/\.?[^.\/]+$/);
                    $key.val(ramdomName);
                    $selectedFile.html('文件：' + selectedFile);
                } else {
                    $.toptips("图片格式不正确");
                    return false;
                }
                var f = new FormData(document.getElementById("testform1"));
                $.ajax({
                    url: upload_domain,  // Different bucket zone has different upload url, you can get right url by the browser error massage when uploading a file with wrong upload url.
                    type: 'POST',
                    data: f,
                    processData: false,
                    contentType: false,
                    xhr: function () {
                        myXhr = $.ajaxSettings.xhr();
                        if (myXhr.upload) {
                            myXhr.upload.addEventListener('progress', function (e) {
                                // console.log(e);
                                if (e.lengthComputable) {
                                    var percent = e.loaded / e.total * 100;
                                    $progress.html('正在上传：' + percent.toFixed(2) + "%");
                                    if(percent === 100){
                                        $progress.html(' ');
                                    }
                                }
                            }, false);
                        }
                        return myXhr;
                    },
                    success: function (res) {
                        console.log("成功：" + JSON.stringify(res));
                        if (res.key) {
                            // that.imgSrc2 = domain + res.key;
                            // console.log(that.imgSrc);
                            that.imgSrc2 = URL.createObjectURL(document.querySelector("#userfile1").files[0]);
                            that.homeForm.idCardVersoPhoto = res.key;
                            $("#hiddenImg1").css("display", "block");
                        }
                    },
                    error: function (res) {
                        console.log("失败:" + JSON.stringify(res));
                        $uploadedResult.html('上传失败：' + res.responseText);
                        $.toptips("失败:" + JSON.stringify(res));
                    }
                });
                return false;
            });
            //formdata  end


        },
        //手持身份证
        uploadhanding: function () {
            var that = this;
            //获取token
            axios.get(that.ctx + '/api/v2/upload/getToken').then(function (res) {
                console.log(res.data);
                if (res.data) {
                    that.token = res.data;
                }
            });


            //formdata  start
            var $key = $('#key');  // file name    eg: the file is image.jpg,but $key='a.jpg', you will upload the file named 'a.jpg'
            var $userfile = $('#userfilehanding1');  // the file you selected

            // upload info
            var $selectedFile = $('.selected-file');
            var $progress = $(".progressHanding");
            var $uploadedResult = $('.uploaded-result');

            $("#userfilehanding1").change(function () {  // you can ues 'onchange' here to uplpad automatically after select a file
                $uploadedResult.html('');
                var selectedFile = $userfile.val();
                if (selectedFile && selectedFile.toLowerCase().match(/\.(jpg|jpeg|png)$/)) {
                    // randomly generate the final file name
                    var ramdomName = Math.random().toString(36).substr(2) + $userfile.val().match(/\.?[^.\/]+$/);
                    $key.val(ramdomName);
                    $selectedFile.html('文件：' + selectedFile);
                } else {
                    $.toptips("图片格式不正确");
                    return false;
                }
                var f = new FormData(document.getElementById("testformhanding1"));
                $.ajax({
                    url: upload_domain,  // Different bucket zone has different upload url, you can get right url by the browser error massage when uploading a file with wrong upload url.
                    type: 'POST',
                    data: f,
                    processData: false,
                    contentType: false,
                    xhr: function () {
                        myXhr = $.ajaxSettings.xhr();
                        if (myXhr.upload) {
                            myXhr.upload.addEventListener('progress', function (e) {
                                // console.log(e);
                                if (e.lengthComputable) {
                                    var percent = e.loaded / e.total * 100;
                                    $progress.html('正在上传：' + percent.toFixed(2) + "%");
                                    if(percent === 100){
                                        $progress.html(' ');
                                    }
                                }
                            }, false);
                        }
                        return myXhr;
                    },
                    success: function (res) {
                        console.log("成功：" + JSON.stringify(res));
                        if (res.key) {
                            // that.imgSrchanding = domain + res.key;
                            that.imgSrchanding = URL.createObjectURL(document.querySelector("#userfilehanding1").files[0]);
                            // console.log(that.imgSrc);
                            that.homeForm.idCardAndPersonPhoto = res.key;
                            $("#hiddenImghanding1").css("display", "block");
                        }
                    },
                    error: function (res) {
                        console.log("失败:" + JSON.stringify(res));
                        $uploadedResult.html('上传失败：' + res.responseText);
                        $.toptips("失败:" + JSON.stringify(res));
                    }
                });
                return false;
            });
            //formdata  end
        },
        //合同照片
        uploadContract: function () {
            $('#userfilecontract').unbind("change");
            document.getElementById("userfilecontract").onchange = null;
            var that = this;
            //获取token
            axios.get(that.ctx + '/api/v2/upload/getToken').then(function (res) {
                console.log(res.data);
                if (res.data) {
                    that.token = res.data;
                }
            });


            //formdata  start
            var $key = $('#key');  // file name    eg: the file is image.jpg,but $key='a.jpg', you will upload the file named 'a.jpg'
            var $userfile = $('#userfilecontract');  // the file you selected

            // upload info
            var $selectedFile = $('.selected-file');
            var $progress = $(".progressContract");
            var $uploadedResult = $('.uploaded-result');

            $("#userfilecontract").change(function () {  // you can ues 'onchange' here to uplpad automatically after select a file
                $uploadedResult.html('');
                var selectedFile = $userfile.val();
                if (selectedFile && selectedFile.toLowerCase().match(/\.(jpg|jpeg|png)$/)) {
                    // randomly generate the final file name
                    var ramdomName = Math.random().toString(36).substr(2) + $userfile.val().match(/\.?[^.\/]+$/);
                    $key.val(ramdomName);
                    $selectedFile.html('文件：' + selectedFile);
                } else {
                    $.toptips("图片格式不正确");
                    return false;
                }
                var f = new FormData(document.getElementById("testformcontract"));
                $.ajax({
                    url: upload_domain,  // Different bucket zone has different upload url, you can get right url by the browser error massage when uploading a file with wrong upload url.
                    type: 'POST',
                    data: f,
                    processData: false,
                    contentType: false,
                    xhr: function () {
                        myXhr = $.ajaxSettings.xhr();
                        if (myXhr.upload) {
                            myXhr.upload.addEventListener('progress', function (e) {
                                // console.log(e);
                                if (e.lengthComputable) {
                                    var percent = e.loaded / e.total * 100;
                                    $progress.html('正在上传：'+ percent.toFixed(2) + "%");
                                    if(percent === 100){
                                        $progress.html(' ');
                                    }
                                }
                            }, false);
                        }
                        return myXhr;
                    },
                    success: function (res) {
                        app.$forceUpdate();
                        console.log("成功：" + JSON.stringify(res));
                        if (res.key) {
                            // that.imgSrccontract = domain + res.key;
                            that.imgSrccontract = URL.createObjectURL(document.querySelector("#userfilecontract").files[0]);
                            // console.log(that.imgSrc);
                            that.homeForm.contractPhotos.push(res.key);
                            console.log(that.homeForm.contractPhotos);
                        }
                    },
                    error: function (res) {
                        console.log("失败:" + JSON.stringify(res));
                        $uploadedResult.html('上传失败：' + res.responseText);
                        $.toptips("失败:" + JSON.stringify(res));
                    }
                });
                return false;
            });
            //formdata  end
        },
        //删除合同照片
        detailPic: function (index) {
            this.homeForm.contractPhotos.splice(index,1)
        },
        //点击页面跳转
        transferClick: function (prop) {
            var that = this;
            if (prop === 'other') {
                //跳转其他信息
                that.nextPage = false;
                that.other = true;
                that.scrollTop = $(window).scrollTop();
            }
            if (prop === 'housingInfo') {
                //跳转房屋信息
                that.nextPage = false;
                that.housingInfo = true;
                that.scrollTop = $(window).scrollTop();
            }
            if (prop === 'housingAddress') {
                //跳转房屋地址
                that.nextPage = false;
                that.housingAddress = true;
                //如果已经选择过了省市区，那么跳转的时候带过来
                if(that.sheng !== ''){
                    Vue.nextTick(function () {
                        $("#s").val(that.sheng)
                    });
                }
                if(that.shi !== ''){
                    Vue.nextTick(function () {
                        $("#shi").val(that.shi)
                    });
                }
                if(that.qu !== ''){
                    Vue.nextTick(function () {
                        $("#qx").val(that.qu)
                    });
                }
                if(that.Form.statusName === '待修改'){
                    Vue.nextTick(function () {
                        that.homeForm.address = that.Form.check.address;
                        that.homeForm.apartmentNo = that.Form.check.apartmentNo;
                        //这里处理省市县的id,回显从后台传过来的省市区县
                        cityPickList.forEach(function(item){
                            //省
                            if(that.Form.check.province === item.value){
                                $("#s").val(item.label);
                                //市
                                item.children.forEach(function(item) {
                                    if(that.Form.check.city === item.value){
                                        $("#shi").val(item.label);
                                        //县
                                        item.children.forEach(function(item) {
                                            if(that.Form.check.district === item.value){
                                                $("#qx").val(item.label);
                                            }
                                        })
                                    }
                                })
                            }
                        });
                    });
                    //更新cityPicker默认选择数组
                    that.cityPickDefault = [that.Form.check.province,that.Form.check.city,that.Form.check.district];
                }
                that.scrollTop = $(window).scrollTop();
            }
            if (prop === 'contract') {
                //跳转租房合同照片
                that.nextPage = false;
                that.contract = true;
                if(that.Form.statusName === '待修改'){
                    Vue.nextTick(function () {
                        that.homeForm.contractPhotos = that.Form.check.contractPhotos;
                    });
                }
                that.scrollTop = $(window).scrollTop();
            }
            // 电子合同
            if (prop === 'depositAndFees') {
                //跳转押金及其他费用
                that.nextPage = false;
                that.depositAndFees = true;
                //默认值
                Vue.nextTick(function () {
                    $('#depositType').val('押一付一');
                });
                that.scrollTop = $(window).scrollTop();
            }
            if(prop === 'removeTerm') {
                //跳转合同解除条件
                that.nextPage = false;
                that.removeTerm = true;
                that.scrollTop = $(window).scrollTop();
            }
            if(prop === 'otherPromiseTips') {
                //跳转其他约定事项
                that.nextPage = false;
                that.otherPromiseTips = true;
                that.scrollTop = $(window).scrollTop();
            }
            if(prop === 'housingList') {
                //跳转房屋交割清单
                that.nextPage = false;
                that.housingList = true;
                that.scrollTop = $(window).scrollTop();
            }
            if(prop === 'otherList') {
                //跳转其他费用List
                that.nextPage = false;
                that.otherList = true;
                that.scrollTop = $(window).scrollTop();
            }
        },
        //省市区picker
        cityPicker: function () {
            var that = this;
            weui.picker(cityPickList, {
                depth: 3,
                defaultValue: that.cityPickDefault,
                onChange: function onChange(result) {
                },
                onConfirm: function onConfirm(result) {
                    that.cityPickResult = result;
                    //赋值
                    $("#s").val(result[0].label);
                    $("#shi").val(result[1].label);
                    $("#qx").val(result[2].label);
                    //获取汉字名称到合同
                    that.homeForm.electroniContractJson.city = result[1].label;
                    that.homeForm.electroniContractJson.district = result[2].label;
                    //获取ID
                    that.homeForm.province = result[0].value;
                    that.homeForm.city = result[1].value;
                    that.homeForm.district = result[2].value;
                    //更新默认选择的数组
                    that.cityPickDefault = [result[0].value,result[1].value,result[2].value];
                },
                id: 'cascadePicker'
            });
        },
        //身份证页面返回
        idCardReturn: function () {
            this.home = true;
            this.idCardPicture = false;
            //当身份证传的时候消除错误验证
            if(this.homeForm.idCardFrontPhoto && this.homeForm.idCardVersoPhoto){
                this.idCardError = true;
                this.idCardClass = '';
                if(this.Form.statusName === '待修改'){
                    this.idCardShow = '已修改';
                } else {
                    this.idCardShow = '已上传'
                }
            }
            var that = this;
            Vue.nextTick(function () {
                $(window).scrollTop(that.scrollTop);
            });
        },
        //手持身份证页面返回
        idCardHandingReturn: function () {
            this.home = true;
            this.idCardHanding = false;
            if(this.homeForm.idCardAndPersonPhoto){
                this.idCardHandingError = true;
                this.idCardHandingClass = '';
                if(this.Form.statusName === '待修改'){
                    this.idCardHandingShow = '已修改';
                } else {
                    this.idCardHandingShow = '已上传'
                }
            }
            var that = this;
            Vue.nextTick(function () {
                $(window).scrollTop(that.scrollTop);
            });
        },
        //租客其他信息返回
        otherReturn: function () {
            var that = this;
            //增加验证
            if(this.otherForm.education === undefined || this.otherForm.education === ''){
                $.toptips("请输入学历");
                return false;
            }
            if(this.otherForm.companyName === undefined || this.otherForm.companyName === ''){
                $.toptips("请输入工作单位");
                return false;
            }
            if(this.otherForm.companyAddress === undefined || this.otherForm.companyAddress === ''){
                $.toptips("请输入单位地址");
                return false;
            }
            if(this.otherForm.emergencyContact === undefined || this.otherForm.emergencyContact === ''){
                $.toptips("请输入紧急联系人");
                return false;
            }
            if(this.otherForm.emergencyPhone === undefined || this.otherForm.emergencyPhone === ''){
                $.toptips("请输入紧急联系人手机号");
                return false;
            }
            if(this.otherForm.emergencyRelation === undefined || this.otherForm.emergencyRelation === ''){
                $.toptips("请输入与联系人关系");
                return false;
            }
            axios.put(that.ctx + '/wxtest/v2/applications/supply/customer',that.otherForm).then(function(res){
                // console.log(res.data);
                if (res.data.status === 200) {
                    that.home = true;
                    that.other = false;
                    that.othertip = '已修改';
                    Vue.nextTick(function () {
                        $(window).scrollTop(that.scrollTop);
                    });
                }else{
                    $.toptips(res.data.message);
                    that.home = true;
                    that.other = false;
                }

            });
        },
        //房屋信息返回
        housingInfoReturn: function () {
            var that = this;
            //加验证
            var monthlyRentValid = /^([1-9][0-9]*)+(.[0-9]{1,2})?$/.test(this.housingForm.monthlyRent);
            if(this.housingForm.monthlyRent === '' || this.housingForm.monthlyRent === undefined){
                $.toptips("请输入月租金");
                return false;
            }
            if(!monthlyRentValid){
                $.toptips("月租金为保留两位小数的正整数");
                return; false;
            }
            console.log(this.housingForm.retainage);
            var retainageValid = /^([1-9][0-9]*)+(.[0-9]{1,2})?$/.test(Number(this.housingForm.retainage));
            if(this.housingForm.retainage === undefined || this.housingForm.retainage === ''){
                $.toptips("请输入尾款，无尾款输入0");
                return false;
            }
            if(Number(this.housingForm.retainage) !== 0){
                if(!retainageValid){
                    $.toptips("尾款不能小于0");
                    return false;
                }
            }

            this.housingForm.startDate = this.housingForm.startDateShow+' 00:00:00';
            this.housingForm.endDate = this.housingForm.endDateShow+' 00:00:00';
            axios.put(that.ctx + '/wxtest/v2/applications/supply/house',that.housingForm).then(function(res){
                if (res.data.status === 200) {
                    that.home = true;
                    that.housingInfo = false;
                    that.housingInfotip = '已修改';
                    Vue.nextTick(function () {
                        $(window).scrollTop(that.scrollTop);
                    });
                } else{
                    $.toptips(res.data.message);
                    that.home = true;
                    that.housingInfo = false;
                }
            });
        },
        //房屋地址信息返回
        housingAddressReturn: function () {
            //获取当前页面填写的省市区
            this.sheng = $("#s").val();
            this.shi = $("#shi").val();
            this.qu = $("#qx").val();
            this.home = true;
            this.housingAddress = false;
            if(this.homeForm.province && this.homeForm.city && this.homeForm.district && this.homeForm.address && this.homeForm.apartmentNo){
                this.housingAddressError = true;
                this.housingAddressClass = '';
                if(this.Form.statusName === '待修改'){
                    this.housingAddressShow = '已修改';
                } else {
                    this.housingAddressShow = '已补充'
                }
            }
            var that = this;
            Vue.nextTick(function () {
                $(window).scrollTop(that.scrollTop);
            });
        },
        //租房合同照片返回
        constractReturn: function () {
            this.home = true;
            this.contract = false;
            if(this.homeForm.contractPhotos.length > 0){
                this.contractError = true;
                this.contractClass = '';
                if(this.Form.statusName === '待修改'){
                    this.contractShow = '已修改';
                } else {
                    this.contractShow = '已上传'
                }
            }
            var that = this;
            Vue.nextTick(function () {
                $(window).scrollTop(that.scrollTop);
            });
        },
        tips: function () {
            weui.confirm('如果在房源库中找不到需要的房源，请打开后方按钮，手工填写房源信息。', {
                title: '温馨提示',
                buttons: [{
                    label: '我知道了',
                    type: 'primary',
                }]
            });
        },
        //电子合同所需方法
        eleContract: function () {
            var that = this;
            if(this.eleContractOpen) {
                that.showTags();
                axios.get(this.ctx + '/wxtest/v2/applications/generateCA/'+this.Form.applictionNo).then(function(res){
                    if(res.data.status === 200) {
                        that.hidenTags();
                        that.homeForm.isElectroniContract = true;//电子合同打开
                        $('#iosDialog2').fadeIn(200);
                        that.fadeClass = 'fadein';
                    } else {
                        weui.topTips(res.data.message);
                        that.hidenTags();
                        that.eleContractOpen = false;
                    }
                }).catch(function () {
                    that.eleContractOpen = false;
                    that.hidenTags();
                });
            } else {
                that.fadeClass = 'fadeout';
                that.homeForm.isElectroniContract = false;
                //关闭佣金
                that.commissionOpen = false;
                that.commissionClass = 'fadeout';
                that.homeForm.electroniContractJson.commissionDays = '';
                that.homeForm.electroniContractJson.commission = '';
                that.homeForm.electroniContractJson.commissionPayType = '';
            }
        },
        commissionClick: function () {
            if(this.commissionOpen) {
                this.commissionClass = 'bb';
                this.fadeClass = 'aa';
            } else {
                this.fadeClass = 'fadein';
                this.commissionClass = 'fadeout';
                //清空已经填写的佣金
                this.homeForm.electroniContractJson.commissionDays = '';
                this.homeForm.electroniContractJson.commission = '';
                this.homeForm.electroniContractJson.commissionPayType = '';
            }
        },
        depositPicker: function () {
            var that = this;
            weui.picker([
                {
                    label: '0',
                    value: '零'
                },
                {
                    label: '1',
                    value: '一'
                }, {
                    label: '2',
                    value: '二'
                }, {
                    label: '3',
                    value: '三'
                },{
                    label: '4',
                    value: '四'
                },{
                    label: '5',
                    value: '五'
                },{
                    label: '6',
                    value: '六'
                }
            ], [
                {
                    label: '1',
                    value: '一'
                }, {
                    label: '2',
                    value: '二'
                }, {
                    label: '3',
                    value: '三'
                },{
                    label: '4',
                    value: '四'
                },{
                    label: '5',
                    value: '五'
                },{
                    label: '6',
                    value: '六'
                },{
                    label: '7',
                    value: '七'
                }, {
                    label: '8',
                    value: '八'
                }, {
                    label: '9',
                    value: '九'
                },{
                    label: '10',
                    value: '十'
                },{
                    label: '11',
                    value: '十一'
                },{
                    label: '12',
                    value: '十二'
                }
            ], {
                className: 'test',
                defaultValue: that.depositPickDefault,
                onChange: function (result) {

                },
                onConfirm: function (result) {
                    //赋值
                    $('#depositType').val('押'+result[0].value+'付'+result[1].value);
                    that.homeForm.electroniContractJson.depositCount = result[0].value;
                    that.homeForm.electroniContractJson.prepaidCount = result[1].value;
                    that.depositPickDefault = [result[0].value,result[1].value];
                },
                id: 'multiPickerBtn'
            });
        },
        //费用种类change
        feeTypeChange1: function () {
            var that = this;
            that.homeForm.electroniContractJson.lessorDuty = [];
            //lessorDuty  甲方承担责任
            that.lessorDuty.forEach(function (item, index) {
                if(item) {
                    that.homeForm.electroniContractJson.lessorDuty.push(index+1);
                }
                Vue.set(that.lesseeDuty,index,!item);
            });
            that.homeForm.electroniContractJson.lesseeDuty = [];
            that.lesseeDuty.forEach(function (item, index) {
                if(item) {
                    that.homeForm.electroniContractJson.lesseeDuty.push(index+1);
                }
            });
        },
        feeTypeChange2: function () {
            //lesseeDuty  乙方承担责任
            var that = this;
            that.homeForm.electroniContractJson.lesseeDuty = [];
            that.lesseeDuty.forEach(function (item, index) {
                if(item) {
                    that.homeForm.electroniContractJson.lesseeDuty.push(index+1);
                }
                Vue.set(that.lessorDuty,index,!item);
            });
            that.homeForm.electroniContractJson.lessorDuty = [];
            that.lessorDuty.forEach(function (item, index) {
                if(item) {
                    that.homeForm.electroniContractJson.lessorDuty.push(index+1);
                }
            });
        },
        feeTypeClick: function (a) {
            if(a === '甲方') {
                if(this.feeType1Bloor1) {
                    this.depositRotate1 = 'rotateY';
                    this.feeType1 = 'depositOpen';
                    this.feeType1Bloor1 = false;
                } else {
                    this.depositRotate1 = 'rotateX';
                    this.feeType1 = 'depositClose';
                    this.feeType1Bloor1 = true;
                }
            }
            if(a === '乙方') {
                if(this.feeType1Bloor2) {
                    this.depositRotate2 = 'rotateY';
                    this.feeType2 = 'depositOpen';
                    this.feeType1Bloor2 = false;
                } else {
                    this.depositRotate2 = 'rotateX';
                    this.feeType2 = 'depositClose';
                    this.feeType1Bloor2 = true;
                }
            }
        },
        //押金及其他费用返回
        depositReturn: function () {
            var that = this;
            this.home = true;
            this.depositAndFees = false;
            Vue.nextTick(function () {
                $(window).scrollTop(that.scrollTop);
            });
        },
        //合同解除条件返回
        removeTermReturn: function () {
            var that = this;
            this.home = true;
            this.removeTerm = false;
            Vue.nextTick(function () {
                $(window).scrollTop(that.scrollTop);
            });
        },
        //其他约定事项返回
        otherPromiseTipsReturn: function () {
            var that = this;
            this.home = true;
            this.otherPromiseTips = false;
            Vue.nextTick(function () {
                $(window).scrollTop(that.scrollTop);
            });
        },
        //房屋交割清单电器类展开
        housingListClick: function (a) {
            if(a === '电器类') {
                if(this.housingListBoolean1) {
                    this.housingListRotate1 = 'rotateY';
                    this.housingListClass1 = 'housingListOpen';
                    this.housingListBoolean1 = false;
                } else {
                    this.housingListRotate1 = 'rotateX';
                    this.housingListClass1 = 'housingListClose';
                    this.housingListBoolean1 = true;
                }
            }
            if(a === '家具类') {
                if(this.housingListBoolean2) {
                    this.housingListRotate2 = 'rotateY';
                    this.housingListClass2 = 'housingListOpen';
                    this.housingListBoolean2 = false;
                } else {
                    this.housingListRotate2 = 'rotateX';
                    this.housingListClass2 = 'housingListClose';
                    this.housingListBoolean2 = true;
                }
            }
        },
        housingListChange: function () {
            //deliveryList
            var List = ['电视机','冰箱','洗衣机','空调','微波炉','热水器','燃气灶','油烟机','饮水机','机顶盒','灭火器','双人床','单人床','衣柜','电脑桌','书桌','书柜','餐厅','床头柜','椅子','电视柜','沙发'];
            var that = this;
            that.homeForm.electroniContractJson.deliveryList = [];
            that.deliveryList.forEach(function (item, index) {
                if(item) {
                    that.homeForm.electroniContractJson.deliveryList.push(List[index]);
                }
            });
        },
        //房屋交割清单返回
        housingListReturn: function () {
            this.home = true;
            this.housingList = false;
            var that = this;
            Vue.nextTick(function () {
                $(window).scrollTop(that.scrollTop);
            });
        },
        //其他费用清单
        otherListDetailClick: function (a) {
            var that = this;
            that.otherList = false;
            that.otherListDetail = true;
            that.otherListDetailDto.items = a;
            that.otherListDetailDto.startDate = '';
            that.otherListDetailDto.baseCount = '';
            that.otherListDetailDto.unit = '';
            that.otherListDetailDto.monovalent = '';
            that.homeForm.electroniContractJson.otherFeeList.forEach(function (item) {
                if(item.items === a) {
                    that.otherListDetailDto.startDate = item.startDate;
                    that.otherListDetailDto.baseCount = item.baseCount;
                    that.otherListDetailDto.unit = item.unit;
                    that.otherListDetailDto.monovalent = item.monovalent;
                }
            })
        },
        otherListReturn: function () {
            var that = this;
            this.home = true;
            this.otherList = false;
            Vue.nextTick(function () {
                $(window).scrollTop(that.scrollTop);
            });
        },
        otherListDetailReturn: function () {
            var that = this;
            var flag = false;
            //把数据暂存到数组中
            var pushObject = Object.assign({},that.otherListDetailDto);
            //如果数组中已经存在，则不Push
            that.homeForm.electroniContractJson.otherFeeList.forEach(function (item, index) {
                if(item.items === pushObject.items) {
                    flag = true;
                    item.startDate = pushObject.startDate;
                    item.baseCount = pushObject.baseCount;
                    item.unit = pushObject.unit;
                    item.monovalent = pushObject.monovalent;
                    //如果值全部为空，则删除该对象
                    if(!item.startDate && !item.baseCount && !item.unit && !item.monovalent) {
                        that.homeForm.electroniContractJson.otherFeeList.splice(index,1);
                        var flagList1 = ['水费','电费','电话费','收视费','供暖费','燃气费','物业费','卫生费','上网费','电卡','水卡','燃气卡','门禁卡','钥匙','停车费','租赁税费'];
                        flagList1.forEach(function (a, index) {
                            if(a === item.items) {
                                that.otherListStatus[index] = false;
                            }
                        })
                    }
                }
            });
            if(!flag){
                //只要填写了一个就添加到数组中，否则不做操作
                if(pushObject.startDate || pushObject.baseCount || pushObject.unit || pushObject.monovalent) {
                    that.homeForm.electroniContractJson.otherFeeList.push(pushObject);
                }
            }
            var flagList = ['水费','电费','电话费','收视费','供暖费','燃气费','物业费','卫生费','上网费','电卡','水卡','燃气卡','门禁卡','钥匙','停车费','租赁税费'];
            flagList.forEach(function (item, index) {
                that.homeForm.electroniContractJson.otherFeeList.forEach(function (a) {
                    if(a.items === item) {
                        that.otherListStatus[index] = true;
                    }
                })
            });
            that.otherList = true;
            that.otherListDetail = false;
        },
        otherDetailPicker: function () {
            var that = this;
            weui.datePicker({
                start:2017,
                end:2020,
                defaultValue: [2017,10,12],
                onChange: function(result){
                },
                onConfirm: function(result){
                    //月份
                    if(result[1].value < 10){
                        if(result[2].value < 10){
                            that.otherListDetailDto.startDate = dateFns.format(result[0].value + '-'+'0' + result[1].value + '-' + '0' + result[2].value,'YYYY-MM-DD');
                        } else {
                            that.otherListDetailDto.startDate = dateFns.format(result[0].value + '-'+'0' + result[1].value + '-' + result[2].value,'YYYY-MM-DD');
                        }
                    } else {
                        if(result[2].value < 10){
                            that.otherListDetailDto.startDate = dateFns.format(result[0].value + '-' + result[1].value + '-' + '0' + result[2].value,'YYYY-MM-DD');
                        } else {
                            that.otherListDetailDto.startDate = dateFns.format(result[0].value + '-' + result[1].value + '-' + result[2].value,'YYYY-MM-DD');
                        }
                    }
                },
                id: 'otherDetailPicker'
            });
        },
        //其他费用清单展开
        otherListClick: function (a) {
            if(a === '水电气等') {
                if(this.otherListBoolean1) {
                    this.otherListListRotate1 = 'rotateY';
                    this.otherListClass1 = 'otherListOpen';
                    this.otherListBoolean1 = false;
                } else {
                    this.otherListListRotate1 = 'rotateX';
                    this.otherListClass1 = 'housingListClose';
                    this.otherListBoolean1 = true;
                }
            }
            if(a === '其他项目') {
                if(this.otherListBoolean2) {
                    this.otherListListRotate2 = 'rotateY';
                    this.otherListClass2 = 'otherListOpen';
                    this.otherListBoolean2 = false;
                } else {
                    this.otherListListRotate2 = 'rotateX';
                    this.otherListClass2 = 'housingListClose';
                    this.otherListBoolean2 = true;
                }
            }
        },
        dropDown: function () {
            Vue.nextTick(function () {
                $('#iosActionsheet').addClass('weui-actionsheet_toggle');
                $('#iosMask').fadeIn(200);
            });
        },
        dropClose: function () {
            Vue.nextTick(function () {
                $('#iosActionsheet').removeClass('weui-actionsheet_toggle');
                $('#iosMask').fadeOut(200);
            });
        },
        //点击房源列表
        houseSourceClick: function () {
            if(!$("#shi").val()) {
                weui.topTips("请选择省市区县");
                return false;
            }

            var that = this;
            that.showTags();
            //请求小家联行城市区县id
            axios.get('/api/partners/areas?app_id=libfintech').then(function(res){
                res.data.data.forEach(function (city) {
                    //这里针对重庆市做特殊处理，因为我们采用的省市区JSON跟龙贷房源的JSON在重庆市名字上有差别
                    if($("#shi").val() === '市辖区' || $("#shi").val() === '县') {
                        if(city.name === '重庆市') {
                            that.city_id = city.id;
                        }
                    }else {
                        if(city.name === $("#shi").val()) {
                            that.city_id = city.id;
                        }
                    }
                });


                axios.get('/api/partners/areas?app_id=libfintech&parent_id='+that.city_id).then(function(res){
                    res.data.data.forEach(function (district) {
                        if(district.name === $("#qx").val()) {
                            that.district_id = district.id;
                        }
                    });
                    if(!that.city_id) {
                        that.hidenTags();
                        weui.topTips('该地区没有房源');
                        return false;
                    }
                    axios.get('/api/partners/rooms?app_id=libfintech&city_id='+that.city_id+'&district_id='+that.district_id).then(function(res){
                        that.hidenTags();
                        if(res.data.data.rooms.length === 0) {
                            weui.topTips('该地区没有房源');
                            return false;
                        }
                        that.housingAddress = false;
                        that.housingSource = true;
                        that.housingSourceData = res.data.data.rooms;
                        that.next_url = res.data.data.next;//是否有更多房源~
                    }).catch(function () {

                    });

                }).catch(function () {

                });
            }).catch(function () {

            });


            //滚动条到页面底部加载更多案例
            $(window).scroll(function(){
                if(that.scrollFlag) {
                    var scrollTop = $(this).scrollTop();    //滚动条距离顶部的高度
                    var scrollHeight = $(document).height();   //当前页面的总高度
                    var clientHeight = $(this).height();    //当前可视的页面高度
                    if(scrollTop + clientHeight >= scrollHeight){   //距离顶部+当前高度 >=文档总高度 即代表滑动到底部
                        if(that.next_url) {
                            that.scrollFlag = false;
                            that.loadingMore = true;
                            axios.get(that.next_url).then(function(res){
                                that.loadingMore = false;
                                that.housingSourceData = that.housingSourceData.concat(res.data.data.rooms);
                                that.scrollFlag = true;
                                that.next_url = res.data.data.next;//是否有更多房源~
                            }).catch(function () {

                            });
                        } else {
                            that.loadingNotMore = true;
                        }


                    }else if(scrollTop<=0){

                    }
                }

            });
        },
        housingSourceDataClick: function (item) {
            this.homeForm.housingSourceDataJson = item;
            //去掉监听滚动事件
            $(window).unbind("scroll");
            this.loadingNotMore = false;
            this.loadingMore = false;
            this.homeForm.address = this.homeForm.housingSourceDataJson.address;
            this.homeForm.electroniContractJson.roomCount = this.homeForm.housingSourceDataJson.apart_name;
            this.homeForm.apartmentNo = this.homeForm.housingSourceDataJson.charge_num;
            this.housingAddress = true;
            this.housingSource = false;
            var that = this;
            Vue.nextTick(function () {
                $("#s").val(that.cityPickResult[0].label);
                $("#shi").val(that.cityPickResult[1].label);
                $("#qx").val(that.cityPickResult[2].label);
            })
        }
    }
});
